﻿// -------------------------------------------------------------------------
//    @FileName         :    NFTransLogicUserBase.h
//    @Author           :    xxxxx
//    @Date             :   xxxx-xx-xx
//    @Email			:    xxxxxxxxx@xxx.xxx
//    @Module           :    NFTransLogicUserBase.h
//
// -------------------------------------------------------------------------

#pragma once

#include "NFComm/NFObjCommon/NFTransBase.h"
#include "NFLogicCommon/NFLogicShmTypeDefines.h"
#include "NFLogicCommon/NFBaseDefine.h"

class NFPlayer;
class NFSession;

class NFTransPlayerBase : public NF_OBJECT_TEMPLATE_MACRO(NFTransPlayerBase, EOT_TRANS_LOGIC_PLAYER_BASE, NFTransBase)
public:
    NFTransPlayerBase();

    virtual ~NFTransPlayerBase();

    int CreateInit();

    int ResumeInit();

    int Init(NFPlayer *pPlayer, uint32_t cmd, uint32_t csSeq, uint32_t fromBusId = 0, uint32_t reqTransId = 0);

    int Init(NFSession *pSession, uint32_t cmd, uint32_t csSeq, uint32_t fromBusId = 0, uint32_t reqTransId = 0);

public:
    int SetClientSession(NFSession *pSession);

    NFSession *GetClientSession() const;

    int GetClientSessionID() const { return m_iClientSessionID; }

    uint16_t GetClientRequestSeq() const { return m_stCSMsgHeadReq.m_iSeqCS; }

    int GetClientRequestMsgID() const { return (int) m_stCSMsgHeadReq.m_iMsgID; }

    const CSMsgHead *GetCSMsgHeadReq() const { return &m_stCSMsgHeadReq; }

    void ClearClientSessionAndPlayer();

    NFPlayer *GetPlayer();

    NFPlayer *Player();

    virtual int OnTimeOut();

    virtual int OnTransFinished(int iRunLogicRetCode);

    virtual int HandleTransFinished(int iRunLogicRetCode);
public:
    std::string GetDebugInfo() const;
protected:
    void SetRoleID(uint64_t ullRoleID) { m_ullRoleID = ullRoleID; }
    uint64_t GetRoleID() const { return m_ullRoleID; }
    uint64_t RoleID() const { return m_ullRoleID; }
protected:
    uint64_t m_ullRoleID;
    int m_iPlayerObjID;
    uint32_t m_fromBusId;
    uint32_t m_reqTransId;
    bool m_bHasIncreasedCount;
    int m_iClientSessionID;
    CSMsgHead m_stCSMsgHeadReq;
};
